
var _oEvent;

function window.onload()
{
	//fields = values in our case bcos we want to reuse the fieldselect.js
	var _oValuesXml		= window.dialogArguments.valuesXml;
	

	// set the global variables for the field select object for our dialog
	//
	_iFieldSelectWidth		= 205;
	_iFieldSelectHeight		= 145;
	_sFieldSelectLeftTitle	=  "Available Values" ;
	_sFieldSelectRightTitle	=  "Selected Values" ;
	_bFieldSelectShowUp		= false;
	_bFieldSelectShowDown	= false;
	
	var oNodes		= _oValuesXml.selectNodes("/TBODY/TR/TD");

	var iLen		= oNodes.length;
	
	var sValuesAry		= new Array(2);
		sValuesAry[0]	= new Array(iLen);
		sValuesAry[1]	= new Array(iLen);

	for (var i = 0; i < iLen; i++)
	{
		sValuesAry[1][i] = oNodes[i].text;
		sValuesAry[0][i] = oNodes[i].getAttribute('val');
		
	}

	//this is in _tools/fieldselect/fieldselect.js
	Quicksort( sValuesAry[1], 0, sValuesAry[0].length - 1, sValuesAry[0] );
	
	var selectedList = window.dialogArguments.sSelectedValues.split(";");
	iLen = selectedList.length;
	var sSelectedAry = new Array(iLen);
	sSelectedAry[0] = new Array(iLen);
	sSelectedAry[1] = new Array(iLen);
	
	var sSelectedName = "";
	
	for (var i = 0; i < iLen; i++)
	{
		sSelectedName = selectedList[i];
		if(sSelectedName == "") continue;
		var oNodes = _oValuesXml.selectNodes("/TBODY/TR/TD");
		for (var j = 0; j < oNodes.length; j++)
		{
			if(oNodes[j].text == sSelectedName)
			{
				sSelectedAry[1][i] = sSelectedName;
				sSelectedAry[0][i] = oNodes[j].getAttribute('val');
				break;					
			}
		}
	}
	
	drawFieldSelect(sValuesAry, sSelectedAry);
	
}

function applychanges()
{
	var oRows	= rtnObjList.firstChild.rows;
	var iLen	= rtnObjList.firstChild.rows.length;

	var sDependsAry	= new Array();
	sDependsAry		= GetReturnList();
	
	window.returnValue	= sDependsAry;

	window.close();
}

function cancel()
{
	window.close();
}
